<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      layout:decorator="inc/layout"
>
<head>
    <meta charset="UTF-8"/>

    <title>首页</title>
    <script th:inline="javascript">
        /*<![CDATA[*/


        function noteBookFind() {
            layer.confirm('您确定要全文检索笔记吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                location.href = ctxPath + "ES/noteBookFind?page=1&key=" + $("#key").val();
            });

        }

        /*]]>*/
    </script>

</head>
<body>
<div class="container" layout:fragment="content">
    <div class="row">
        <div class="col-sm-6" style="height: 80px">
            <div class="h3 text-center" th:text="'关键字 '+${key}+':共搜索到'+${coursePage.totalElements}+' 条课程记录'"></div>
        </div>
        <div class="col-sm-6" style="height: 80px">
            <form class="form-inline text-right" action="" method="get">
                <div class="form-group">
                    <div class="input-group">
                        <div class="input-group-addon">课程名</div>
                        <input type="text" id="key" class="form-control" name="key" th:value="${key}"
                               placeholder="hibernate"/>
                    </div>
                </div>
                <button type="submit" class="btn btn-primary">搜索</button>
                <shiro:hasPermission name="检索笔记">
                    <button type="button" class="btn btn-primary" onclick="noteBookFind()">搜索笔记</button>
                </shiro:hasPermission>
            </form>
        </div>
    </div>
    <div class="row">

        <div class="col-sm-2">
            <div class=" panel panel-default">
                <div class="panel-heading "><i class="fa fa-search"></i>搜索引擎</div>
                <div class="panel-body h4 text-center">
                    欢迎使用<br/>
                    课程全文搜索
                </div>

                <div class="panel-footer text-center">
                    <a th:href="@{/}">返回首页</a>
                </div>


            </div>
        </div>
        <div class="col-sm-10">

            <div class="col-sm-3" th:each="c:${coursePage.content}">
                <div class="thumbnail">

                    <a th:href="@{'/show/'+${c.id}}">
                        <img th:src="${c.img}" onerror="this.src='/img/course/default.jpg'"/>
                    </a>
                    <div class="caption">
                        <div class="h4" th:text="${c.name}"></div>
                        <span th:if="${c.courseTypes.size()==0}" class="mytip hidden-xs hidden-sm"
                              style="margin-bottom: 10px;display: inline-block">未分类</span>
                        <span th:each="t:${c.courseTypes}" th:text="${t.name}" class="mytip hidden-xs hidden-sm"
                              style="margin-bottom: 10px;display: inline-block"></span>
                        <a th:href="@{'/show/'+${c.id}}" class="btn btn-default pull-right">查看</a>
                    </div>
                </div>
            </div>
            <div class="row" th:if="${coursePage.totalElements>0}">
                <div class="col-sm-10">
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                            <li class="am-pagination-first ">
                                <a th:href="@{/ES/courseFind(page=1,key=${key})}" class="">第一页</a>
                            </li>
                            <li th:if="${coursePage.number > 0}" class="am-pagination-prev ">
                                <a th:href="@{/ES/courseFind(page=${coursePage.number},key=${key})}" class="">上一页</a>
                            </li>
                            <li th:each="i : ${#numbers.sequence(1, coursePage.totalPages)}"
                                th:classappend="${(coursePage.number + 1) eq i} ? 'active' : ''">
                                <a th:href="@{/ES/courseFind(page=${i},key=${key})}"
                                   th:text="${i}" class="">1</a>
                            </li>
                            <li th:unless="${coursePage.number + 1 == coursePage.totalPages}"
                                class="am-pagination-next ">
                                <a th:href="@{/ES/courseFind(page=${coursePage.number} + 2,key=${key})}"
                                   class="">下一页</a>
                            </li>
                            <li class="am-pagination-last ">
                                <a th:href="@{/ES/courseFind(page=${coursePage.totalPages},key=${key})}"
                                   class="">最末页</a>
                            </li>
                            <li class="am-pagination-last ">
                                <a th:text="'共 '+${coursePage.totalElements}+' 条记录'"></a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
    </div>


</div>
</body>
</html>